#ifndef __MEM_BUDDY_H__
#define __MEM_BUDDY_H__

#include "types.h"

typedef struct mem_buddy_ks
{
    object_kt o;

    word_kt heap_base;
    word_kt heap_limit;
    word_kt pool_base;
    word_kt pool_limit;

    list_kt*  oarr_free_head;   /* array cnt < maxorder, point to free list head*/
    list_kt*  barr_list;    /* array cnt < block num, point to list array                       */
    uint8_kt* barr_order;   /* array cnt < block num, point to block size array                   */
    uint8_kt* barr_attri;   /* array cnt < block num, point to block attribute array                */

    word_kt   page_count;
    word_kt   page_shift;
    word_kt   max_order;

}   mem_buddy_kt, *mem_buddy_kp;

bool_kt k_mem_buddy_init(mem_buddy_kp pBdy, word_kt order, void* base, void* limit,word_kt f_malloc, word_kt f_free);
void* k_mem_buddy_malloc(mem_buddy_kp pBdy, word_kt size);
bool_kt k_mem_buddy_free(mem_buddy_kp pBdy, void* addr);

#endif
